<%@ page language="java" isELIgnored="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:directive.include file="/WEB-INF/sitemesh-decorators/include.jsp" />
<fmt:setBundle basename="bundles.folder-resources" />
<meta id="${add_folder_success}">

<script type="text/javascript">
   Wicket.Event.add(window, "domready", function(event) {
      $('#addLink').click(function() {
         $('#hiddenArea').slideDown(250);
         $('#addLink').hide();
         $('#addLinkAlt').show();
         $('input[name=folderName]').focus();
      });
      $('#cancelAddFolder,#downarrow').click(function() {
         $('#hiddenArea').slideUp(250);
         $('#addLink').show();
         $('#addLinkAlt').hide();
         $('input[name=folderName]').val('');
      });
   });
</script>
<script type="text/javascript">
   $(document).ready(function() {
      $('#addFolderLink').click(function() {
         //alert(1);
         var parentID = $('input[name=parentID]').val();
         var folderName = $('input[name=folderName]').val();

         $.ajax({
            url : '${pageContext.request.contextPath}/ajax/folder/add',
            type : "POST",
            data: { parentID: parentID, folderName: folderName },
            dataType : "html",
            beforeSend : function() {
               $('#wait').show();
            },
            complete : function() {
               $('#wait').hide();
            },
            success : function(data) {
               if ($(data).first().attr("id") == "add_folder_success") {
                  $('#hiddenArea').html(data);
                  $('input[name=folderName]').val('');
                  $('#document-content').load('${pageContext.request.contextPath}/ajax/folder/' + parentID);
               } else {
                  $('#hiddenArea').html(data);
                  //$('#document-content').html(data);
                  //$('#hiddenArea').slideUp(250);
                  //$('#addLink').show();
                  //$('#addLinkAlt').hide();
                  //$('#folderName.errors').remove();
               }
            },
            error : function(xhr, ajaxOptions, thrownError) {
               openDeniedDialog('Alert', xhr.responseText);
            }
         });
         return false;
      });
   });
</script>
<form:form id="frmFolder" action="" method="post" commandName="folderForm">
   <div style="width: 0px; height: 0px; position: absolute; left: -100px; top: -100px; overflow: hidden">
      <%--<input name="parentID" id="parentID" value="${currentFolderID}" type="hidden" />--%>
      <form:hidden id="parentID" path="parentID"/>
   </div>
   <div class="panel_content">
      <ul>
         <li class="title"><fmt:message key="folder.name.title" /> 
            <form:input id="folderName" path="folderName" class="Text Full" />
            <form:errors path="folderName" cssStyle="color:red" />
         </li>
      </ul>
   </div>
   <div class="panel_btn">
      <div class="cancel">
         <a class="action" href="javascript:;" id="cancelAddFolder">cancel</a>
      </div>
      <a id="addFolderLink" class="gcSubmit small" href="#">Save <span class="left"></span> <span class="right"></span>
      </a>
   </div>
</form:form>